<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>联系人信息</title>
	<style type="text/css">
    	.even{background-color: #FFFF99}
    	.odd{background-color: #FF99FF}
    	tr:hover{background-color: #FF3300}
    </style>
</head>
<body style="text-align: center;">
	<h2 align="center">联系人信息</h2>
      <table  align="center" border="1" width="100%">
        <tr>
		  <td >序号</td>
          <td >姓名</td>
          <td >电话</td>
          <td >电子邮件</td>
          <td >QQ</td>
          <td >所在分组</td>
		  <td >操作</td>
        </tr>
        <c:forEach var="contact" items="${requestScope.pagebean.list}" varStatus="status">
        <tr class="${status.count%2==0?'even':'odd' }">
        	<td>${contact.contactid }</td>
        	<td>${contact.contactname }</td>
        	<td>${contact.phone }</td>
        	<td>${contact.email }</td>
        	<td>${contact.qq }</td>
        	<td>${contact.groupid }</td>
        	<td>
        		<a href="${pageContext.request.contextPath }/servlet/EditContactServlet?id=${contact.contactid}">修改</a>
    			<a href="javascript:void(0)" onclick="del('${contact.contactid}')">删除</a>
        	</td>
        </tr>
        </c:forEach>
      </table>
    <script type="text/javascript">
    	function del(id){
    		if(window.confirm("您确认删除吗？？")){
    			location.href='${pageContext.request.contextPath}/servlet/DelContactServlet?id='+id;
    		}
    	}
    	
    	function gotopage(currentpage){
    		var pagesize = document.getElementById("pagesize").value;
    		window.location.href = '${pageContext.request.contextPath}/servlet/ContactListServlet?currentpage='+currentpage+'&pagesize='+pagesize;
    	}
    </script>
    
              共[${pagebean.totalrecord }]条记录,
              每页<input type="text" id="pagesize" value="${pagebean.pagesize }" onchange="gotopage(${pagebean.currentpage })" style="width: 30px" maxlength="2"/>条，
              共[${pagebean.totalpage }]页，
              当前[${pagebean.currentpage }]页
    &nbsp;&nbsp;&nbsp;
    <a href="javascript:void(0)" onclick="gotopage(${pagebean.previouspage})">上一页</a>
    	<c:forEach var="pagenum" items="${pagebean.pagebar}">
    		<c:if test="${pagenum==pagebean.currentpage}">
    			<font color="red">${pagenum }</font>
    		</c:if>
    		<c:if test="${pagenum!=pagebean.currentpage}">
    		<a href="javascript:void(0)" onclick="gotopage(${pagenum})">${pagenum }</a>
    		</c:if>
    	</c:forEach>
    <a href="javascript:void(0)" onclick="gotopage(${pagebean.nextpage})">下一页</a>
  	
  	<input type="text" id="pagenum" style="width: 30px">
  	<input type="submit" value=" GO " onclick="gotopage(document.getElementById('pagenum').value)">
  	
  </body>
</html>